/*
 * Copyright 2008 Zoundry LLC, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package org.zoundry.gaedt.ui.views.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.zoundry.gaedt.core.util.ZGaeUtil;
import org.zoundry.gaedt.sdk.ZGaeSDKActivator;
import org.zoundry.gaedt.ui.ZGaeUIImages;

/**
 * Implements the SDK View's "Check for Updates" action.
 */
public class ZGaeCheckForUpdatesAction extends Action
{
    /**
     * C'tor.
     */
    public ZGaeCheckForUpdatesAction()
    {
        setText("Check for Updates");
        setToolTipText("Checks for SDK updates by connecting to Google's web site and checking to see if a new SDK is available.");
        setImageDescriptor(ZGaeUIImages.getImageDescriptor("icons/views/sdk/checkForUpdates.png"));
    }

    /**
     * @see org.eclipse.jface.action.Action#run()
     */
    @Override
    public void run()
    {
        String title = "Check For GAE SDK Updates?";
        String message = "Checking for updates to the SDK will create a background task/job which will connect to Google and check for a newer version of the SDK.  Do you wish to continue?";
        if (MessageDialog.openConfirm(ZGaeUtil.getShell(), title, message))
        {
            ZGaeSDKActivator.getDefault().updateSDK();
            ZGaeUtil.showView("org.eclipse.ui.views.ProgressView");
        }
    }

}
